package com.dmooo.yxmmerchant.view.model;

import android.content.Context;

import com.common.net.entity.SubjectPost;
import com.common.net.listener.HttpOnNextListener;
import com.common.net.subscribers.ProgressSubscriber;
import com.dmooo.yxmmerchant.http.HttpManager;
import com.dmooo.yxmmerchant.view.contract.ChangePhonePwdContract;

import java.util.HashMap;
import java.util.Map;

public class ChangePhonePwdModel implements ChangePhonePwdContract.ChangeMdl {
    private Context context;
    public ChangePhonePwdModel(Context context) {
        this.context=context;
    }

    @Override
    public void sendOldPhone(String token, HttpOnNextListener listener) {
        Map<String,Object> map=new HashMap<>();
        map.put("token",token);
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,true,false,"登录中"),map);
        HttpManager.getInstance().sendChangeBandCode(post);
    }

    @Override
    public void sendNewPhone(String phone, HttpOnNextListener listener) {
        Map<String,Object> map=new HashMap<>();
        map.put("phone",phone);
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,true,false,"登录中"),map);
        HttpManager.getInstance().sendChangeBanding(post);
    }

    @Override
    public void changePwd(String token, String oldPwd, String newPwd, String newPwd2, HttpOnNextListener listener) {
        Map<String,Object> map=new HashMap<>();
        map.put("token",token);
        map.put("oldpwd",oldPwd);
        map.put("pwd1",newPwd);
        map.put("pwd2",newPwd2);
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,true,false,"修改中"),map);
        HttpManager.getInstance().changePwd(post);
    }

    @Override
    public void changePhone(String token, String old_code, String phone, String code, HttpOnNextListener listener) {
        Map<String,Object> map=new HashMap<>();
        map.put("token",token);
        map.put("old_code",old_code);
        map.put("phone",phone);
        map.put("code","code");
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,true,false,"登录中"),map);
        HttpManager.getInstance().changeBandingPhone(post);
    }

    @Override
    public void getResetPhoneCode(String phone, HttpOnNextListener listener) {
        Map<String,Object> map=new HashMap<>();
        map.put("phone",phone);
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,true,false,"登录中"),map);
        HttpManager.getInstance().sendUserFindpwd(post);
    }

    @Override
    public void resetPhonePwd(String phone, String code, String pwd, HttpOnNextListener listener) {
        Map<String,Object> map=new HashMap<>();
        map.put("phone",phone);
        map.put("code",code);
        map.put("pwd",pwd);
        SubjectPost post=new SubjectPost(new ProgressSubscriber(listener,context,true,false,"登录中"),map);
        HttpManager.getInstance().findPwdByPhone(post);
    }
}
